//
//  CZCommentView.swift
//  GZWeibo007
//
//  Created by apple on 15/12/24.
//  Copyright © 2015年 Apple. All rights reserved.
//

import UIKit

protocol CZCommentViewDelegate:NSObjectProtocol
{
    func commentViewBtnDidClick();
}

//评论View
class CZCommentView: UIView {
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    override init(frame: CGRect) {
        super.init(frame: frame)
        backgroundColor = UIColor(white: 0.99, alpha: 1)
        prepareUI()
        
    }
    
    var status:CZStatus?
        {
        didSet{
            commentBtn.setTitle("评论数 \(status!.comments_count)", forState: UIControlState.Normal)
        }
    }
 
    //代理
    weak var delegate:CZCommentViewDelegate?

    //添加UI
    func prepareUI() {
        addSubview(commentBtn)
        
        commentBtn.ff_AlignInner(type: ff_AlignType.CenterLeft, referView: self, size: nil, offset: CGPoint(x: 10, y: 0))
        
    }
    
    func btnDidClick()
    {
        delegate?.commentViewBtnDidClick()
    }
 
    //创建评论按钮
    private lazy var commentBtn: UIButton = {
        let button = UIButton()
        button.titleLabel?.font = UIFont.systemFontOfSize(14)
        button.setTitleColor(UIColor.blackColor(), forState: UIControlState.Normal)
        button.addTarget(self, action: "btnDidClick", forControlEvents: UIControlEvents.TouchUpInside)
        return button
    }()

}
